﻿using UnityEngine;
using System.Collections;

public static class Extendsion
{
    public static int ToInt(this string str)
    {
        
        int i = 0;
        if(!int.TryParse(str , out i))
        {
            Debug.LogError("string format error!!");
        }
        return i;
    }

	public static float ToFloat(this string str)
    {
        float i = 0;
        if (!float.TryParse(str, out i))
        {
            Debug.LogError("string format error!!");
        }
        return i;
    }

    public static Transform SetPosX(this Transform tran ,  int posX)
    {
        Vector3 vec = tran.position;
        tran.position = new Vector3(posX, vec.y, vec.z);
        return tran;
    }

    public static Transform SetPosY(this Transform tran, int posY)
    {
        Vector3 vec = tran.position;
        tran.position = new Vector3(vec.x, posY, vec.z);
        return tran;
    }

    public static Transform SetPosZ(this Transform tran, int posZ)
    {
        Vector3 vec = tran.position;
        tran.position = new Vector3(vec.x, vec.y, posZ);
        return tran;
    }

    public static Transform SetRotX(this Transform tran, int rotX)
    {
        Vector3 vec = tran.eulerAngles;
        tran.eulerAngles = new Vector3(rotX, vec.y, vec.z);
        return tran;
    }

    public static Transform SetRotY(this Transform tran, int rotY)
    {
        Vector3 vec = tran.eulerAngles;
        tran.eulerAngles = new Vector3(vec.x, rotY, vec.z);
        return tran;
    }

    public static Transform SetRotZ(this Transform tran, int rotZ)
    {
        Vector3 vec = tran.eulerAngles;
        tran.eulerAngles = new Vector3(vec.x, vec.y, rotZ);
        return tran;
    }

    


}
